# import pandas as pd
# pd.set_option('display.unicode.east_asian_width',True)
# df=pd.DataFrame([['A','C','B'],['B','A','C'],['A','B','C'],['A','B','C']],columns=['a','b','c'])
# print('原始数据:\n',df)
# print('按频数降序统计a列:\n',df.value_counts('a'))
# print('按频率升序统计b列:\n',df.value_counts('b',normalize=True,ascending=True))
# print('按频数降序统计所有列:\n',df.value_counts())
# print('使用describe()函数统计所有列:\n',df.describe())

import pandas as pd
pd.set_option('display.unicode.east_asian_width',True)
df=pd.read_excel('产品订单信息表.xlsx')
df1=pd.crosstab(index=df['性别'],columns=df['产品类型'])
print('统计性别和商品类型交叉频数的数据df1:\n',df)
df2=pd.crosstab(index=df['性别'],columns=df['产品类型'],margins=True)
print('统计和汇总性别和商品类型交叉频数的数据df2:\n',df2)
df3=pd.crosstab(index=df['性别'],columns=df['产品类型'],margins=True,normalize=True)
print('统计和汇总性别和商品类型交叉频率的数据df3:\n',df3)
df4=pd.crosstab(index=df['性别'],columns=df['产品类型'],margins=True,margins_name='总数',normalize='index')
print('按行统计和汇总性别和商品类型交叉频数的数据df4:\n',df4)